package cn.kongwg.myproxy;

import net.sf.cglib.proxy.Enhancer;

/**
 * @author kongwg
 * @create 2021-05-16 12:37
 */
public class Client {
    public static void main(String[] args) {

        // 创建动态代理增强类
        Enhancer enhancer = new Enhancer();
        // 设置类加载器
        enhancer.setClassLoader(MeleSinger.class.getClassLoader());
        // 设置被代理类
        enhancer.setSuperclass(MeleSinger.class);
        // 设置方法拦截器
        enhancer.setCallback(new DebugMethodInterceptor());
        // 创建代理类
        MeleSinger meleSinger = (MeleSinger) enhancer.create();
        meleSinger.sing();
    }
}
